package com.gxc.config;

import com.gxc.interceptor.LoginInterceptor;
import java.util.LinkedList;
import java.util.List;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置.
 *
 * @author 宫新程
 * @since 2018/12/15 4:52 PM
 */
@Configuration
public class WebConfigBean implements WebMvcConfigurer {

  /** 添加拦截器. */
  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    LoginInterceptor loginInterceptor = new LoginInterceptor();
    List<String> url = new LinkedList<>();
    url.add("/bootstrap-3.3.7-dist/**");
    url.add("/css/**");
    url.add("/fonts/**");
    url.add("/images/**");
    url.add("/js/**");
    registry.addInterceptor(loginInterceptor).addPathPatterns("/**").excludePathPatterns(url);
  }
}
